<style lang="scss" scoped>
</style>
<template>
  <div>
    <div v-for="(row,rindex) in row" :key="rindex">
      <div v-for="(col,cindex) in col" :key="cindex" :style="'width:'+colwidth[cindex]+';'">{{data[rindex][cindex]}}</div>
    </div>
  </div>
</template>
<script>
export default {
  name: "linetable",
  data() {
    return {
      row: 0,
      col: 0,
      colwidth: [50, 100, 50],
      data: [
        ["系统操作", "3号控房调试", "已完成"],
        ["系统操作", "3号控房调试", "已完成"],
        ["系统操作", "3号控房调试", "已完成"]
      ]
    };
  },
  props: {
    _row: {
      type: Number,
      required: true
    },
    _col: {
      type: Number,
      required: true
    },
    _colwidth: {
      type: Array,
      required: true
    },
    _data: {
      type: Array,
      required: true
    }
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.data = this._data;
      if (this._row != undefined) {
        this.row = this._row;
      } else {
        this.row = this._data.length;
      }
      if (this._col != undefined) {
        this.col = this._col;
      } else {
        this.col = this._data[0].length;
      }
      if (this._colwidth != undefined) {
        this.colwidth = this._colwidth;
      } else {
        this.data.forEach((element, index) => {
          this.colwidth.push(100);
        });
      }
    }
  }
};
</script>